package com.misday.eatup;

import com.misday.eatup.model.FoodsDatabaseHelper;
import com.mobclick.android.MobclickAgent;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

public class AboutActivity extends Activity {
	
	private ImageButton mBackBtn;
	private Activity mActivity;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		mActivity = this;
		
		this.setContentView(R.layout.activity_about);
		
		TextView app_ver = (TextView)this.findViewById(R.id.app_ver);
		TextView db_ver = (TextView)this.findViewById(R.id.db_ver);
		
		String appVer = Utility.getVersionName(this, AboutActivity.class);
		app_ver.setText(appVer);
		db_ver.setText("" + FoodsDatabaseHelper.DATABASE_VERSION);
		
		mBackBtn = (ImageButton)this.findViewById(R.id.back);
		mBackBtn.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				mActivity.finish();
			}
		});
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		
		MobclickAgent.onPause(this);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		
		MobclickAgent.onResume(this);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		MenuInflater inflater = this.getMenuInflater();
		inflater.inflate(R.menu.about_menu, menu);

		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		switch (item.getItemId()) {
		case R.id.menu_check_db_version:
			//
			return true;
		}

		return super.onOptionsItemSelected(item);
	}
}
